.class public Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil;
.super Ljava/lang/Object;
.source "CameraFlashLightUtil.java"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil$FlashLightListener;
    }
.end annotation


# static fields
.field private static listenerList:Ljava/util/List;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/List",
            "<",
            "Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil$FlashLightListener;",
            ">;"
        }
    .end annotation
.end field

.field private static mCamera:Landroid/hardware/Camera;

.field private static mIsFlightOpen:Z


# direct methods
.method static constructor <clinit>()V
    .registers 1

    .prologue
    .line 17
    const/4 v0, 0x0

    sput-boolean v0, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil;->mIsFlightOpen:Z

    return-void
.end method

.method public constructor <init>()V
    .registers 1

    .prologue
    .line 14
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 114
    return-void
.end method

.method public static isFlashlightOpen()Z
    .registers 1

    .prologue
    .line 111
    sget-boolean v0, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil;->mIsFlightOpen:Z

    return v0
.end method

.method public static declared-synchronized openFlashlight(Landroid/view/SurfaceView;)Z
    .registers 10
    .param p0, "surfaceView"    # Landroid/view/SurfaceView;

    .prologue
    const/4 v7, 0x1

    const/4 v6, 0x0

    .line 23
    const-class v8, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil;

    monitor-enter v8

    :try_start_5
    sget-object v5, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil;->mCamera:Landroid/hardware/Camera;
    :try_end_7
    .catch Ljava/lang/Throwable; {:try_start_5 .. :try_end_7} :catch_7f
    .catchall {:try_start_5 .. :try_end_7} :catchall_a1

    if-nez v5, :cond_4a

    .line 26
    :try_start_9
    invoke-static {}, Landroid/hardware/Camera;->open()Landroid/hardware/Camera;

    move-result-object v5

    sput-object v5, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil;->mCamera:Landroid/hardware/Camera;
    :try_end_f
    .catch Ljava/lang/Exception; {:try_start_9 .. :try_end_f} :catch_16
    .catch Ljava/lang/Throwable; {:try_start_9 .. :try_end_f} :catch_7f
    .catchall {:try_start_9 .. :try_end_f} :catchall_a1

    .line 31
    :goto_f
    :try_start_f
    sget-object v5, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil;->mCamera:Landroid/hardware/Camera;
    :try_end_11
    .catch Ljava/lang/Exception; {:try_start_f .. :try_end_11} :catch_22
    .catch Ljava/lang/Throwable; {:try_start_f .. :try_end_11} :catch_7f
    .catchall {:try_start_f .. :try_end_11} :catchall_a1

    if-nez v5, :cond_41

    move v5, v6

    .line 67
    :goto_14
    monitor-exit v8

    return v5

    .line 27
    :catch_16
    move-exception v0

    .line 28
    .local v0, "e":Ljava/lang/Exception;
    :try_start_17
    invoke-virtual {v0}, Ljava/lang/Exception;->printStackTrace()V

    .line 29
    const/4 v5, 0x0

    invoke-static {v5}, Landroid/hardware/Camera;->open(I)Landroid/hardware/Camera;

    move-result-object v5

    sput-object v5, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil;->mCamera:Landroid/hardware/Camera;
    :try_end_21
    .catch Ljava/lang/Exception; {:try_start_17 .. :try_end_21} :catch_22
    .catch Ljava/lang/Throwable; {:try_start_17 .. :try_end_21} :catch_7f
    .catchall {:try_start_17 .. :try_end_21} :catchall_a1

    goto :goto_f

    .line 36
    .end local v0    # "e":Ljava/lang/Exception;
    :catch_22
    move-exception v0

    .line 38
    .restart local v0    # "e":Ljava/lang/Exception;
    :try_start_23
    invoke-virtual {v0}, Ljava/lang/Exception;->printStackTrace()V

    .line 39
    sget-object v5, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil;->listenerList:Ljava/util/List;

    if-eqz v5, :cond_7d

    .line 40
    const/4 v1, 0x0

    .local v1, "i":I
    :goto_2b
    sget-object v5, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil;->listenerList:Ljava/util/List;

    invoke-interface {v5}, Ljava/util/List;->size()I

    move-result v5

    if-ge v1, v5, :cond_7d

    .line 41
    sget-object v5, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil;->listenerList:Ljava/util/List;

    invoke-interface {v5, v1}, Ljava/util/List;->get(I)Ljava/lang/Object;

    move-result-object v5

    check-cast v5, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil$FlashLightListener;

    invoke-interface {v5}, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil$FlashLightListener;->onTurnFail()V
    :try_end_3e
    .catch Ljava/lang/Throwable; {:try_start_23 .. :try_end_3e} :catch_7f
    .catchall {:try_start_23 .. :try_end_3e} :catchall_a1

    .line 40
    add-int/lit8 v1, v1, 0x1

    goto :goto_2b

    .line 34
    .end local v0    # "e":Ljava/lang/Exception;
    .end local v1    # "i":I
    :cond_41
    :try_start_41
    invoke-virtual {p0}, Landroid/view/SurfaceView;->getHolder()Landroid/view/SurfaceHolder;

    move-result-object v3

    .line 35
    .local v3, "mSurfaceHolder":Landroid/view/SurfaceHolder;
    sget-object v5, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil;->mCamera:Landroid/hardware/Camera;

    invoke-virtual {v5, v3}, Landroid/hardware/Camera;->setPreviewDisplay(Landroid/view/SurfaceHolder;)V
    :try_end_4a
    .catch Ljava/lang/Exception; {:try_start_41 .. :try_end_4a} :catch_22
    .catch Ljava/lang/Throwable; {:try_start_41 .. :try_end_4a} :catch_7f
    .catchall {:try_start_41 .. :try_end_4a} :catchall_a1

    .line 48
    .end local v3    # "mSurfaceHolder":Landroid/view/SurfaceHolder;
    :cond_4a
    :try_start_4a
    sget-object v5, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil;->mCamera:Landroid/hardware/Camera;

    invoke-virtual {v5}, Landroid/hardware/Camera;->getParameters()Landroid/hardware/Camera$Parameters;

    move-result-object v2

    .line 49
    .local v2, "mParameters":Landroid/hardware/Camera$Parameters;
    const-string v5, "torch"

    invoke-virtual {v2, v5}, Landroid/hardware/Camera$Parameters;->setFlashMode(Ljava/lang/String;)V

    .line 50
    sget-object v5, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil;->mCamera:Landroid/hardware/Camera;

    invoke-virtual {v5, v2}, Landroid/hardware/Camera;->setParameters(Landroid/hardware/Camera$Parameters;)V

    .line 51
    sget-object v5, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil;->mCamera:Landroid/hardware/Camera;

    invoke-virtual {v5}, Landroid/hardware/Camera;->startPreview()V

    .line 53
    const/4 v5, 0x1

    sput-boolean v5, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil;->mIsFlightOpen:Z

    .line 54
    sget-object v5, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil;->listenerList:Ljava/util/List;

    if-eqz v5, :cond_9e

    .line 55
    const/4 v1, 0x0

    .restart local v1    # "i":I
    :goto_67
    sget-object v5, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil;->listenerList:Ljava/util/List;

    invoke-interface {v5}, Ljava/util/List;->size()I

    move-result v5

    if-ge v1, v5, :cond_9e

    .line 56
    sget-object v5, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil;->listenerList:Ljava/util/List;

    invoke-interface {v5, v1}, Ljava/util/List;->get(I)Ljava/lang/Object;

    move-result-object v5

    check-cast v5, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil$FlashLightListener;

    invoke-interface {v5}, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil$FlashLightListener;->onTurnOn()V
    :try_end_7a
    .catch Ljava/lang/Throwable; {:try_start_4a .. :try_end_7a} :catch_7f
    .catchall {:try_start_4a .. :try_end_7a} :catchall_a1

    .line 55
    add-int/lit8 v1, v1, 0x1

    goto :goto_67

    .end local v1    # "i":I
    .end local v2    # "mParameters":Landroid/hardware/Camera$Parameters;
    .restart local v0    # "e":Ljava/lang/Exception;
    :cond_7d
    move v5, v6

    .line 44
    goto :goto_14

    .line 59
    .end local v0    # "e":Ljava/lang/Exception;
    :catch_7f
    move-exception v4

    .line 60
    .local v4, "t":Ljava/lang/Throwable;
    :try_start_80
    sget-object v5, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil;->listenerList:Ljava/util/List;

    if-eqz v5, :cond_9b

    .line 61
    const/4 v1, 0x0

    .restart local v1    # "i":I
    :goto_85
    sget-object v5, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil;->listenerList:Ljava/util/List;

    invoke-interface {v5}, Ljava/util/List;->size()I

    move-result v5

    if-ge v1, v5, :cond_9b

    .line 62
    sget-object v5, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil;->listenerList:Ljava/util/List;

    invoke-interface {v5, v1}, Ljava/util/List;->get(I)Ljava/lang/Object;

    move-result-object v5

    check-cast v5, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil$FlashLightListener;

    invoke-interface {v5}, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil$FlashLightListener;->onTurnFail()V
    :try_end_98
    .catchall {:try_start_80 .. :try_end_98} :catchall_a1

    .line 61
    add-int/lit8 v1, v1, 0x1

    goto :goto_85

    .end local v1    # "i":I
    :cond_9b
    move v5, v6

    .line 65
    goto/16 :goto_14

    .end local v4    # "t":Ljava/lang/Throwable;
    .restart local v2    # "mParameters":Landroid/hardware/Camera$Parameters;
    :cond_9e
    move v5, v7

    .line 67
    goto/16 :goto_14

    .line 23
    .end local v2    # "mParameters":Landroid/hardware/Camera$Parameters;
    :catchall_a1
    move-exception v5

    monitor-exit v8

    throw v5
.end method

.method public static registerFlashLightListener(Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil$FlashLightListener;)V
    .registers 2
    .param p0, "flashLightListener"    # Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil$FlashLightListener;

    .prologue
    .line 97
    sget-object v0, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil;->listenerList:Ljava/util/List;

    if-nez v0, :cond_b

    .line 98
    new-instance v0, Ljava/util/ArrayList;

    invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V

    sput-object v0, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil;->listenerList:Ljava/util/List;

    .line 100
    :cond_b
    sget-object v0, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil;->listenerList:Ljava/util/List;

    invoke-interface {v0, p0}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    .line 101
    return-void
.end method

.method public static declared-synchronized turnOff()Z
    .registers 6

    .prologue
    const/4 v3, 0x0

    .line 72
    const-class v4, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil;

    monitor-enter v4

    :try_start_4
    sget-object v2, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil;->mCamera:Landroid/hardware/Camera;

    if-eqz v2, :cond_4b

    .line 73
    sget-object v2, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil;->mCamera:Landroid/hardware/Camera;

    invoke-virtual {v2}, Landroid/hardware/Camera;->getParameters()Landroid/hardware/Camera$Parameters;

    move-result-object v1

    .line 74
    .local v1, "mParameters":Landroid/hardware/Camera$Parameters;
    invoke-virtual {v1}, Landroid/hardware/Camera$Parameters;->getFlashMode()Ljava/lang/String;

    move-result-object v2

    const-string v5, "off"

    if-eq v2, v5, :cond_4b

    .line 75
    const-string v2, "off"

    invoke-virtual {v1, v2}, Landroid/hardware/Camera$Parameters;->setFlashMode(Ljava/lang/String;)V

    .line 76
    sget-object v2, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil;->mCamera:Landroid/hardware/Camera;

    invoke-virtual {v2, v1}, Landroid/hardware/Camera;->setParameters(Landroid/hardware/Camera$Parameters;)V

    .line 78
    sget-object v2, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil;->mCamera:Landroid/hardware/Camera;

    invoke-virtual {v2}, Landroid/hardware/Camera;->stopPreview()V

    .line 79
    sget-object v2, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil;->mCamera:Landroid/hardware/Camera;

    invoke-virtual {v2}, Landroid/hardware/Camera;->release()V

    .line 80
    const/4 v2, 0x0

    sput-object v2, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil;->mCamera:Landroid/hardware/Camera;

    .line 81
    const/4 v2, 0x0

    sput-boolean v2, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil;->mIsFlightOpen:Z

    .line 82
    sget-object v2, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil;->listenerList:Ljava/util/List;

    if-eqz v2, :cond_4b

    .line 83
    const/4 v0, 0x0

    .local v0, "i":I
    :goto_35
    sget-object v2, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil;->listenerList:Ljava/util/List;

    invoke-interface {v2}, Ljava/util/List;->size()I

    move-result v2

    if-ge v0, v2, :cond_4b

    .line 84
    sget-object v2, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil;->listenerList:Ljava/util/List;

    invoke-interface {v2, v0}, Ljava/util/List;->get(I)Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil$FlashLightListener;

    invoke-interface {v2}, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil$FlashLightListener;->onTurnOff()V
    :try_end_48
    .catch Ljava/lang/Throwable; {:try_start_4 .. :try_end_48} :catch_4e
    .catchall {:try_start_4 .. :try_end_48} :catchall_51

    .line 83
    add-int/lit8 v0, v0, 0x1

    goto :goto_35

    .line 89
    .end local v0    # "i":I
    :cond_4b
    const/4 v2, 0x1

    .line 93
    :goto_4c
    monitor-exit v4

    return v2

    .line 90
    :catch_4e
    move-exception v2

    move v2, v3

    .line 93
    goto :goto_4c

    .line 72
    :catchall_51
    move-exception v2

    monitor-exit v4

    throw v2
.end method

.method public static unRegisterFlashLightListener(Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil$FlashLightListener;)V
    .registers 2
    .param p0, "flashLightListener"    # Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil$FlashLightListener;

    .prologue
    .line 104
    sget-object v0, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil;->listenerList:Ljava/util/List;

    if-eqz v0, :cond_6

    if-nez p0, :cond_7

    .line 108
    :cond_6
    :goto_6
    return-void

    .line 107
    :cond_7
    sget-object v0, Lcom/zuiapps/suite/utils/device/CameraFlashLightUtil;->listenerList:Ljava/util/List;

    invoke-interface {v0, p0}, Ljava/util/List;->remove(Ljava/lang/Object;)Z

    goto :goto_6
.end method
